import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
      tabList:[],
      menuDefault:{
          index:'',
          path:''
      },
      user: {
          
      }
  },
  getters: {
  },
  mutations: {
      updateList(state, val) {
          state.tabList.push(val);
      },
      deleteTag(state, index) {
          state.tabList.splice(index, 1);
      },
      updateMenu(state, val) {
          state.menuDefault.index = val.index;
          state.menuDefault.path = val.path;
      },
      updateUser(state, val) {
          state.user = val;
      }
  },
  actions: {
      ADD_TAGS({commit}, val) {
          commit('updateList', val);
      },
      DELETE_TAGS({commit}, index) {
          commit('deleteTag', index)
      },
      ADD_MENU({commit}, val) {
          commit('updateMenu', val)
      }
  },
  modules: {
  },
  plugins:[createPersistedState()]
})
